
var list = []
import Mock from 'mockjs'
for(var i=0;i<200;i++){
    list.push({
        id:Mock.mock('@guid'),//id
        num:Mock.mock('@increment'),//编号
        odd:Mock.mock('@integer(100)'), //单号
        title:Mock.mock('@cparagraph(2)'),//标题
        name:Mock.mock('@cname()'),//报警人
        time:Mock.mock('@datetime'),//时间
        address:Mock.mock('@county(true)'),//案发地址
        police:Mock.mock('@integer(1, 6)'),//接线员
        policeMan:Mock.mock('@id'),//派警员
        type:Mock.mock('@integer(0, 2)'),//状态
        // operator:Mock.mock('@cname')//操作
        
    })
 }
 import { param2Obj } from '../utls/utilsDemo'
 export default {
    getHomeData:(config)=>{
        var { keyword ,page,pageSize}=param2Obj(config.url)
        // console.log('config',config)
        console.log(param2Obj(config.url))
        var newARr =list.filter(item=>item.name.indexOf(keyword) != -1)
        var pageResul = newARr.filter((item,index)=>{
            return (page-1)*pageSize<=index && index<page*pageSize
        })
        return{
           code:200,
           masg:'请求成功',
           data:pageResul,
           total:list.length//总条数
        }
    },
    deleteData:(config)=>{
        var id = JSON.parse(config.body).id
        // console.log('id',id)
        list.forEach((item,index)=>{
            if(item.id==id){
                list.splice(index,1)
            }
        })
        return{
           code:200,
           masg:'删除成功',
           data:null
        }
    },
}